package app.caretrack.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "ServicePlans")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ServicePlan extends NamedBaseModel {

    private List<Machine> machineList;

    private List<Service> serviceList;

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinTable(name = "ServicePlans_Machines", inverseJoinColumns = @JoinColumn(name = "Machines_Id"), joinColumns = @JoinColumn(name = "ServicePlans_Id"))
    public List<Machine> getMachineList() {
        return this.machineList;
    }

    public void setMachineList(List<Machine> machineList) {
        this.machineList = machineList;
    }

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH, mappedBy = "servicePlan")
    public List<Service> getServiceList() {
        return this.serviceList;
    }

    public void setServiceList(List<Service> serviceList) {
        this.serviceList = serviceList;
    }

}
